package Application;

import XmlLoader.FGObjectStructure;
import XmlLoader.FGObjectTrajectoryStructure;
import XmlLoader.Position;

public class TrajFilter {
	
	public static boolean isSamplePointSmallAmount(FGObjectTrajectoryStructure traj, int num) {		
		return (traj.GET002_nNumberOfPoint() < num);
	}
	
	public static boolean isLargeObjBbox(FGObjectTrajectoryStructure traj, int length, int width, double maxSize){
		int index = 0;
		boolean isError = false;
		while(!isError && index < traj.GET002_nNumberOfPoint()) {
			FGObjectStructure getP = traj.GET003_elementIn_list_fGObject(index);
			if(getP.GET005_boxSize()[0] > maxSize * length || getP.GET005_boxSize()[1] > maxSize * width) {
				isError = true;
			}
			index = index + 1;
		}
		return isError;
	}
	
	public static boolean isSmallMoveDist(FGObjectTrajectoryStructure traj, double maxDist) {
		return (traj.ACT005_countStartEndDist() < maxDist);
	}
	
	public static boolean isInRange(FGObjectTrajectoryStructure traj, Position posLeftTop, Position posRightDown) {
		boolean isInBox = false;
		int indexP = 0;
		Position getP = null;
		while(!isInBox && indexP < traj.GET002_nNumberOfPoint()) {
			getP = traj.GET003_elementIn_list_fGObject(indexP).GET001_centerReal();
			if((getP.x >= posLeftTop.x && getP.x <= posRightDown.x) && 
			   (getP.y >= posLeftTop.y && getP.y <= posRightDown.y)) {
				isInBox = true;
			}
			indexP = indexP + 1;
		}
		return isInBox;
	}
}
